package com.jeecg.school.dao.impl;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.apache.ibatis.session.SqlSession;
import org.springframework.stereotype.Repository;

import com.jeecg.school.dao.IStudentDao;
import com.jeecg.school.entity.StudentEntity;

@Repository("studentDao")
public class StudentDaoImpl implements IStudentDao {

	@Override
	public int getStudentCount() throws IOException {
		SqlSession sqlSession = null;
		sqlSession = DBAccess.getSqlSession();//获取SqlSession对象
                //这里要主意了下面文章解释
		int count = sqlSession.selectOne("studentMapper.getCount");
		sqlSession.close();
		return count;
	}

	@Override
	public int getStudentCountByTeacher(Map<String, String> param) throws IOException {
		SqlSession sqlSession = null;
		sqlSession = DBAccess.getSqlSession();//获取SqlSession对象
                //这里要主意了下面文章解释
		int count = sqlSession.selectOne("studentMapper.getCountByTeacher", param);
		sqlSession.close();
		return count;
	}

	@Override
	public List<StudentEntity> queryListByTeacher(Map<String, String> param) throws IOException {
		List<StudentEntity> studentList = new ArrayList<>();
		SqlSession sqlSession = null;
		sqlSession = DBAccess.getSqlSession();//获取SqlSession对象
                //这里要主意了下面文章解释
		studentList = sqlSession.selectList("studentMapper.queryListByTeacher", param);
		sqlSession.close();
		return studentList;
	}

}
